home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieCinematografo.py < prev    next >
Text File  |  2008-11-17  |  5KB  |  153 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieCinematografo.py 1040 2008-11-15 21:13:49Z mikej06 $'
  4.  
  5. # Copyright (c) 2005-2007 Vasco Nunes, Piotr O┼╝arowski
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils, movie, string
  25.  
  26. plugin_name = "Cinematografo"
  27. plugin_description = "Rivista del Cinematografo dal 1928"
  28. plugin_url = "www.cinematografo.it"
  29. plugin_language = _("Italian")
  30. plugin_author = "Vasco Nunes, Piotr O┼╝arowski"
  31. plugin_author_email = "<vasco.m.nunes@gmail.com>"
  32. plugin_version = "1.1"
  33.  
  34. class Plugin(movie.Movie):
  35.     def __init__(self, id):
  36.         self.encode='iso-8859-1'
  37.         self.movie_id = id
  38.         self.url = "http://www.cinematografo.it/bancadati/consultazione/schedafilm.jsp?codice=%s" % str(self.movie_id)
  39.  
  40.     def get_image(self):
  41.         "Find the film's poster image"
  42.         tmp_poster = gutils.trim(self.page, "../images_locandine/%s/"%self.movie_id, ".JPG\"")
  43.         if tmp_poster != "":
  44.             self.image_url = "http://www.cinematografo.it/bancadati/images_locandine/%s/%s.JPG" % (self.movie_id, tmp_poster)
  45.         else:
  46.             self.image_url=""
  47.  
  48.     def get_o_title(self):
  49.         "Find the film's original title"
  50.         self.o_title = gutils.trim(self.page, ">Titolo Originale</font>", "</tr>")
  51.         self.o_title = string.capwords(self.o_title)
  52.  
  53.     def get_title(self):
  54.         """Find the film's local title.
  55.         Probably the original title translation"""
  56.         self.title = gutils.trim(self.page, "<!--TITOLO-->", "<!--FINE TITOLO-->")
  57.         self.title = gutils.trim(self.title, "<b>", "</b>")
  58.         self.title = string.capwords(self.title)
  59.  
  60.     def get_director(self):
  61.         "Find the film's director"
  62.         self.director = gutils.trim(self.page, ">Regia", "Attori<")
  63.         self.director = self.director.replace("  ", " ")
  64.         self.director = gutils.strip_tags(self.director)
  65.         self.director = string.strip(self.director)
  66.  
  67.     def get_plot(self):
  68.         "Find the film's plot"
  69.         self.plot = gutils.trim(self.page, "\"fontYellowB\">Trama</font>", "\n")
  70.  
  71.     def get_year(self):
  72.         "Find the film's year"
  73.         self.year = gutils.trim(self.page, ">Anno</font>", "</tr>")
  74.         self.year = gutils.after(self.year, "\n                  ")
  75.         self.year = gutils.before(self.year, "\n")
  76.  
  77.     def get_runtime(self):
  78.         "Find the film's running time"
  79.         self.runtime = gutils.trim(self.page, ">Durata</font>", "</tr>")
  80.         self.runtime = gutils.after(self.runtime, "\n                  ")
  81.         self.runtime = gutils.before(self.runtime, "\n")
  82.  
  83.     def get_genre(self):
  84.         "Find the film's genre"
  85.         self.genre = gutils.trim(self.page, ">Genere</font>", "</tr>").lower()
  86.  
  87.     def get_cast(self):
  88.         "Find the actors. Try to make it comma separated."
  89.         self.cast = gutils.trim(self.page, ">Attori</font>", "\n")
  90.         self.cast = string.replace(self.cast, "target='_self'>", "\n>")
  91.         self.cast = string.replace(self.cast, "  ", ' ')
  92.         self.cast = string.replace(self.cast, "<a>",_(" as "))
  93.         self.cast = string.replace(self.cast, "</tr><tr>", '\n')
  94.         self.cast = string.replace(self.cast, "...vedi il resto del cast", '')
  95.  
  96.     def get_classification(self):
  97.         "Find the film's classification"
  98.         self.classification = ""
  99.  
  100.     def get_studio(self):
  101.         "Find the studio"
  102.         self.studio = string.capwords(gutils.trim(self.page, ">Distribuzione</font>", "</tr>"))
  103.  
  104.     def get_o_site(self):
  105.         "Find the film's oficial site"
  106.         self.o_site = ""
  107.  
  108.     def get_site(self):
  109.         "Find the film's imdb details page"
  110.         self.site = self.url
  111.  
  112.     def get_trailer(self):
  113.         "Find the film's trailer page or location"
  114.         self.trailer = ""
  115.  
  116.     def get_country(self):
  117.         "Find the film's country"
  118.         self.country = gutils.trim(self.page, ">Origine</font>", "</tr>")
  119.  
  120.     def get_rating(self):
  121.         """Find the film's rating. From 0 to 10.
  122.         Convert if needed when assigning."""
  123.         self.rating = 0
  124.  
  125. class SearchPlugin(movie.SearchMovie):
  126.     "A movie search object"
  127.     def __init__(self):
  128.         self.encode='iso-8859-1'
  129.         self.original_url_search = "http://www.cinematografo.it/bancadati/consultazione/trovatitoli.jsp?tipo=CONTIENEPAROLE&word="
  130.         self.translated_url_search = self.original_url_search
  131.  
  132.     def search(self, parent_window):
  133.         "Perform the web search"
  134.         self.open_search(parent_window)
  135.         self.sub_search()
  136.         return self.page
  137.  
  138.     def sub_search(self):
  139.         "Isolating just a portion (with the data we want) of the results"
  140.         self.page = gutils.trim(self.page, "<td valign=\"top\" width=\"73%\" bgcolor=\"#4d4d4d\">", "</td>")
  141.  
  142.     def get_searches(self):
  143.         "Try to find both id and film title for each search result"
  144.         elements = string.split(self.page, "<li>")
  145.         self.number_results = elements[-1]
  146.  
  147.         if (elements[0] != ''):
  148.             for element in elements:
  149.                 self.ids.append(gutils.trim(element, "?codice=", "\">"))
  150.                 self.titles.append(gutils.convert_entities(gutils.trim(element, "<b>", "</b>")))
  151.         else:
  152.             self.number_results = 0
  153.